<template>
  <div>
    <PDthirdTop ref="PDthirdTop" :orderInfo="orderInfo" :orLiInfo="orLiInfo"/>
  
    <!-- 第三方撰写回来的资料 -->
    <PatentWrite ref="PatentWrite" :orderInfo="orderInfo" :orLiInfo="orLiInfo" />

    <PDmiddle ref="PDmiddle" :orderInfo="orderInfo" :orLiInfo="orLiInfo"/>
    <!-- <PatentHasInfo ref="PatentHasInfo" :orderInfo="orderInfo" :orLiInfo="orLiInfo"/> -->

    <PDthird ref="PDthird" :orderInfo="orderInfo" :orLiInfo="orLiInfo"/>
   
  </div>
</template>



<script>
import PatentWrite from "./common/patentWrite";
import PDthird from "./common/pDthird";
// import PatentHasInfo from "./common/patentHasInfo";


import PDthirdTop from './common/pDthirdTop';
import PDmiddle from './common/pDmiddle';
export default {
  name: "patentThird",
  components: {PDthirdTop,PDthird,PDmiddle,PatentWrite},
  data() {
    let {
      $route:{
        query:{
          order_id
        }
      }
    }=this;
    let data = {
      order_id,
      orLiInfo:{},//商品订单详情
      orderInfo:{}//服务订单详情
    };
    let tool = {};
    return Object.assign(data, tool);
  },
  created(){
    this.getData();
  },
  watch:{
    orLiInfo(newVal,oldVal){
      let {
        orderInfo
      }=this;
      if($app.judgeData(newVal) &&$app.judgeData(orderInfo) ){
        this.doNow(orderInfo);
      }
    },
    orderInfo(newVal,oldVal){
      let {
        orLiInfo
      }=this;
      if($app.judgeData(newVal) &&$app.judgeData(orLiInfo) ){
        this.doNow(newVal);
      }
    }
  },
  mounted() {
    
  },
  methods:{
    // 立刻处理的事情
    doNow(orderInfo){
      let {
        $route:{
          query:{
            pW_List_warn
          }
        }
      }=this;

      let {
        write_state,// 撰写状态,0默认取专利状态,1撰写中,2撰写完成待确认,3撰写完成
        write_contact_unread_count,//撰写留言未读数量
        inventor_name_list,//发明人
        applicant_name_list//申请人
      }=orderInfo;

      this.$nextTick(()=>{
        switch( parseInt(pW_List_warn) ){
          case 1://补充资料
            // 申请人，发明人都为空，才强制性去补充资料
            if(!$app.judgeData(inventor_name_list) && !$app.judgeData(applicant_name_list) ){
              this.$refs['PDthirdTop'].ttW();
            }
          break;
          case 2://留言
            // 撰写留言未读数量 >0 
            if(write_contact_unread_count>0){
              this.$refs['PDthirdTop'].xTxG();
            }
          break;

          case 3://待确认
            if(write_state==2){
              this.$refs['PatentWrite'].zCw();
            }
            
          break;
        };
      });
      
    },

    getData(){
      let {order_id}=this;
      //订单详情
      $ajax.orderInfo(order_id,resData=>{
        this.orLiInfo=resData;

        if($app.is103_108_132(resData.goods_type)){
          //恭喜你来对了地方
        }else{
          $app.toast('该订单暂无详情', false, () => {
            $app.closeTag(this.$route)// 关闭本页面
          });
        }
        
      });
      //专利详情
      $ajax.itwPT(order_id,resData=>{
        // resData.state=5;//待缴申请费
        this.orderInfo=resData;
      });
    }
  }
};
</script>

